package com.tencent;

/**
 * @className: com.tencent.BitPlus
 * @description:
 * @author: tong.li
 * @createTime: 2023/2/23 21:28
 * @copyright: Tongcheng-Elong Holdings Limited
 */
public class BitPlus {

    public static void main(String[] args) {
        System.out.println(p(3, 5));
        System.out.println(is2(5));
    }

    public static boolean is2(int n) {
        return n > 0 && (n & (n-1)) == 0;
    }

    public static int p(int a, int b) {
        int sum = a;
        while (b != 0) {
            sum = a ^ b;
            b = (a & b) << 1;
            a = sum;
        }
        return sum;
    }
}
